export default {

	methods: {


		//获取工单的服务历程
		async GetOrderServiceHistory(WoGuid) {
			let userPhone = this.UserInfo.mobile;
			let token = this.UserInfo.RetId;
			let result = await this.woprogressservice.GetOrderServiceHistory(userPhone, WoGuid, token);
			if (result.RetBool == true) {
				let data = JSON.parse(result.RetObject);
				this.serviceHistoryData = data;
				console.log(data);

			} else {
				uni.showToast({
					title: result.RetMsg,
					icon: "none"
				});
			}
			uni.hideLoading();
		},

		//根据经纬度查出地址名称
		async getLocationAddress(lon, lat) {
			let params = {
				location: `${lat},${lon}`
			}
			let result = await this.mapApiService
				.geoMultipParamMapAsync(this.qqMapServiceUrl, "/ws/geocoder/v1", params);
			return result;
		},

		async GetCurrentAddress() {
			try {
				let mylocation = await this.uniApiPromise.GetLocationPromise();

				this.SetCurrentAddress(mylocation);
			} catch (error) {
				if (error.errMsg == "getLocation:fail auth deny") {
					let modelRes = await this.uniApiPromise.showModalPromise();
					if (modelRes && modelRes.confirm) {
						uni.hideLoading();
						let settingRes = await this.uniApiPromise.OpenSettingPromise();
						if (settingRes &&
							settingRes.authSetting["scope.userLocation"] === true) {
							let mylocation = await this.uniApiPromise.GetLocationPromise();
							this.SetCurrentAddress(mylocation);
						} else {
							uni.hideLoading();
						}
					} else {
						uni.hideLoading();
						uni.showToast({
							icon: "none",
							title: "没有授权"
						})
					}
				}
			}
		},

		//获取当前位置
		async SetCurrentAddress(result) {
			let data = await this.getLocationAddress(result.longitude, result.latitude);
			this.address = data.result.address;
		},

	},
}
